package cn.jcby.app.lebu.controller.req;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author: lihaotian
 * @since: 2023/12/8 01:24
 * @description
 **/
@Data
@ApiModel(value = "修改用户请求实体类", description = "修改用户请求实体类")
public class UpdateUserReq {

    @ApiModelProperty(value = "用户昵称")
    private String nickname;
    @ApiModelProperty(value = "用户头像")
    private String faceUrl;
    @ApiModelProperty("昵称")
    private String nickName;

    /**
     * 性别：1男0女
     */
    @ApiModelProperty("性别:1男0女")
    private Integer gender;


    /**
     * 出生日期
     */
    @ApiModelProperty("出生日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;


    /**
     * 身高:cm
     */
    @ApiModelProperty("身高:cm")
    private BigDecimal height;


    /**
     * 体重：kg
     */
    @ApiModelProperty("体重：kg")
    private BigDecimal weight;


    /**
     * 星座:字典
     */
    @ApiModelProperty("星座字典")
    private String constellation;




    /**
     * 职业：字典
     */
    @ApiModelProperty("职业字典")
    private String occupation;


    /**
     * 血型：A,B,AB,O,其他
     */
    @ApiModelProperty("血型字典")
    private String blood;

    /**
     * 运动频率，字典
     */
    @ApiModelProperty("运动频率字典")
    private String motionFrequency;

    @ApiModelProperty("标签")
    private List<String> tagList;
    @ApiModelProperty("邀请码")
    private String parentInviteCode ;

    public void check(){
        Assert.isFalse(gender!=null && (gender<0 || gender>1),"性别只能选0和1");
        Assert.isFalse(height!=null && height.compareTo(new BigDecimal(300))>0,"身高不能超过300cm");
        Assert.isFalse(height!=null && height.compareTo(BigDecimal.ZERO)<1,"身高不能低于0cm");

        Assert.isFalse(weight!=null && weight.compareTo(new BigDecimal(500))>0,"体重不能超过500kg");
        Assert.isFalse(weight!=null && weight.compareTo(BigDecimal.ZERO)<1,"体重不能低于0kg");

        Assert.isFalse(StringUtils.isNotBlank(parentInviteCode) && parentInviteCode.length()!=6,"邀请码长度只能为6");
    }

}
